"""
创建话题页面
"""
from pom.basepage import BasePage
class CreatePage(BasePage):

    def __init__(self,driver):
        super().__init__(driver)
        self.__tab_xpath = '//*[@resource-id="org.cnodejs.android.md:id/spn_tab"]'
        self.__title_xpath='//*[@resource-id="org.cnodejs.android.md:id/edt_title"]'
        self.__content_xpath='//*[@resource-id="org.cnodejs.android.md:id/edt_content"]'
        self.__publish_btn_xpath='//*[@resource-id="org.cnodejs.android.md:id/action_send"]'

    def select_tab(self,tabname):
        """
        选择选项框
        :param tabname: 版块名字
        :return:
        """
        self.driver.find_element_by_xpath(self.__tab_xpath).click()
        self.driver.find_element_by_xpath(f'//*[@text="{tabname}"]').click()

    def type_title(self,title):
        title_area = self.driver.find_element_by_xpath(self.__title_xpath)
        title_area.clear()
        title_area.send_keys(title)

    def type_content(self,content):
        content_area = self.driver.find_element_by_xpath(self.__content_xpath)
        content_area.clear()
        content_area.send_keys(content)

    def click_publish_btn(self):
        self.driver.find_element_by_xpath(self.__publish_btn_xpath).click()

